package com.zhaojiadi.thinking.in.spring.ioc.overview.domain;

import com.zhaojiadi.thinking.in.spring.ioc.overview.enums.City;
import lombok.Data;
import lombok.ToString;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.core.io.Resource;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;
import java.util.Properties;

/**
 * @Description:
 */
@Data
public class User implements BeanNameAware {

    private Long id;

    private String name;

    private City city;

    private City[] workCities;

    private List<City> lifeCities;

    private Resource configFileLocation;

    private Company company;

    private Properties context;

    private String contextAsText;

    private transient String beanName;

    public static User createUser(){
        User user = new User();
        user.setId(1L);
        user.setName("zhaojiadi");
        return user;
    }

    @Override
    public void setBeanName(String name) {
        this.beanName=name;
    }

    @PostConstruct
    public void init(){
        System.out.println("User Bean ["+beanName+"] 初始化...");
    }

    @PreDestroy
    public void destory(){
        System.out.println("User Bean ["+beanName+"] 销毁中...");
    }


}
